package cn.dkk.create_design.prototype.shallow_clone_prototype.specific;

/**
 * 浅克隆原型的案例
 * <p>
 * 复制奖状
 */
public class Certificate implements Cloneable {

    private String name;

    private Certificate() {
    }

    static class CertificateFactory{

        public static Certificate getInstance() {
            return new Certificate(null);
        }

    }

    public Certificate(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    protected Object clone(String peopleName) throws CloneNotSupportedException {
        Certificate certificate = (Certificate) super.clone();
        certificate.setName(peopleName);
        return certificate;
    }

    @Override
    public String toString() {
        return "奖状" + "\\n" + "获奖人:" + name;
    }
}
